import { AppRegistry } from 'react-native';
import { name as appName } from '../app.json';
import React from 'react'
import dva from './common/utils/dva'
import Router, { routerMiddleware, routerReducer } from './router'
//
import AppModel from './common/redux/models/app';
import UserModel from './common/redux/models/user';
import ShopModel from './common/redux/models/shop';
//
console.log('Dva launching');
console.ignoredYellowBox = ['Warning: BackAndroid is deprecated. Please use BackHandler instead.', 'source.uri should not be an empty string', 'Invalid props.style key'];
console.disableYellowBox = true // 关闭全部黄色警告
/**
 *
 */

if (__DEV__) {
    global.XMLHttpRequest = global.originalXMLHttpRequest
        ? global.originalXMLHttpRequest
        : global.XMLHttpRequest
    global.FormData = global.originalFormData
        ? global.originalFormData
        : global.FormData

    fetch // Ensure to get the lazy property

    if (window.__FETCH_SUPPORT__) {
        // it's RNDebugger only to have
        window.__FETCH_SUPPORT__.blob = false
    } else {
        /*
        * Set __FETCH_SUPPORT__ to false is just work for `fetch`.
        * If you're using another way you can just use the native Blob and remove the `else` statement
        */
        global.Blob = global.originalBlob ? global.originalBlob : global.Blob
        global.FileReader = global.originalFileReader
            ? global.originalFileReader
            : global.FileReader
    }
}

const app = dva({
    initialState: {},
    models: [
        AppModel,
        UserModel,
        ShopModel
    ],
    extraReducers: { router: routerReducer },
    onAction: [routerMiddleware],
    onError(e) {
        console.log('onError', e)
    },
})

const App = app.start(<Router />)
AppRegistry.registerComponent(appName, () => App);